package cn.qingyun.gis.modules.baogan.controller;

import cn.qingyun.gis.common.Result;
import cn.qingyun.gis.modules.baogan.service.MicroStreetDataService;
import cn.qingyun.gis.modules.baogan.vo.AggRequest;
import cn.qingyun.gis.modules.baogan.vo.request.SceneRequest;
import cn.qingyun.gis.modules.init.system.constant.enums.PointType;
import cn.qingyun.gis.modules.scenes.service.IPoiScenarioService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;

/**
 * @author wz
 * @version JDK 8
 * @className MapAggregateController
 * @date 2024/11/6
 * @description 地图聚合
 */
@RestController
@Slf4j
@RequestMapping("/admin/mapAgg")
public class MapAggregateController {
    @Resource
    private IPoiScenarioService poiScenarioService;
    @Resource
    private MicroStreetDataService streetDataService;

    /**
     * 地图聚合接口
     * @param request
     * @return
     */
    @PostMapping("/aggList")
    public Result<?> list(@Validated @RequestBody AggRequest request){
        return Result.okData(poiScenarioService.selectAggList(request));
    }

    /**
     *
     * @param code 编码
     * @param flag 看管标识
     * @return
     */
    @GetMapping("/scenario/total")
    public Result<?> aggScenario(@RequestParam(value = "code",required = true) String code,@RequestParam(value = "flag",required = false) Integer flag){
        return Result.okData(poiScenarioService.aggScenario(code,flag));
    }

    /**
     * 获取场景列表
     * @param request
     * @return
     */
    @PostMapping("/scenario/list")
    public Result<?> selectSceneList(@RequestBody SceneRequest request){
        return Result.okData(poiScenarioService.selectSceneList(request));
    }

    /**
     * 查询微网格企业列表
     * @param microGridCode
     * @param id 面数据id
     * @return
     */
    @GetMapping("/microGrid/enterprise/list")
    public Result<?> selectMicroEnterpriseList(@RequestParam(value = "microGridCode",required = false) String microGridCode, @RequestParam(value = "id",required = false) String id){
        return Result.okData(poiScenarioService.selectMicroEnterpriseList(microGridCode,id));
    }

    /**
     * 查询微网格/面/点详情
     * @param microGridCode
     * @param id
     * @return
     */
    @GetMapping("/microGrid/detail")
    public Result<?> selectMicroDetail(@RequestParam(value = "microGridCode",required = true) String microGridCode, @RequestParam(value = "id",required = false) String id){
        return Result.okData(poiScenarioService.selectMicroDetail(microGridCode,id));
    }

    /**
     * 查询面详情
     * @param microGridCode
     * @param id
     * @return
     */
    @GetMapping("/street/detail")
    public Result<?> selectStreetDetail(@RequestParam(value = "microGridCode",required = true) String microGridCode, @RequestParam(value = "id",required = false) String id){
        return Result.okData(streetDataService.selectStreetDetail(microGridCode,id));
    }

    /**
     * 查询点详情
     * @param microGridCode
     * @param id
     * @return
     */
    @GetMapping("/point/detail")
    public Result<?> selectPointDetail(@RequestParam(value = "microGridCode",required = true) String microGridCode, @RequestParam(value = "id",required = false) String id){
        return Result.okData(poiScenarioService.selectPointDetail(microGridCode,id));
    }
}
